package org.yangspring.samples.mvc.service;

import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
import org.yangspring.samples.mvc.dao.BooksDao;
import org.yangspring.samples.mvc.dao.BooksDaoImpl;
import org.yangspring.samples.mvc.domain.BooksTPerC;

import java.util.List;

import static java.lang.System.out;

/**
 * Created by whyang on 2017/06/19.
 */

@Service
public class BooksTPerCServiceImpl implements BooksTPerCService {

    private static final Logger logger = LoggerFactory.getLogger(BooksTPerCServiceImpl.class);

    @Autowired
    private BooksDao bookDao;
    /*public void setBookDao(BooksDao dao){
        this.bookDao = dao;
    }*/

    @Transactional
    public void addBook(BooksTPerC book){
        logger.warn("\n\n\tBook Service add\n\n");
        this.bookDao.addBook(book);
    }

    @Transactional
    public void updateBook(BooksTPerC book){
        this.bookDao.updateBook(book);
    }

    @Transactional
    public List<BooksTPerC> listBook(){
        logger.warn("\n\nBooks Service list\n\n");
        return this.bookDao.listBook();
    }

    @Transactional
    public BooksTPerC getBookById(long id){
        return this.bookDao.getBookById(id);
    }

    @Transactional
    public void removeBook(long id){
        logger.warn("\n\nBooks Service remove\n\n");
        this.bookDao.removeBook(id);
    }

}
